/**
 * Created By wifi_uncle on 2020/2/12
 */
import API from '../api'
import request from "./request";

export default {
  /**
   * 获取省份列表
   * @param _this
   * @returns {PromiseLike<any> | Promise<any> | * | n}
   */
  getProvinceList ({_this}) {
    let url = API.COMMON.GET_PROVINCE_LIST
    return request({
      _this,
      errorMsg: '获取省份列表失败',
      body: { params: {} },
      url,
      method: 'post'
    }).then(rsp => rsp.resData.areaList)
  },
  /***
   * 获取城市列表
   */
  getCityList ({_this, provinceId = 0}) {
    let url =  API.COMMON.GET_CITY_LIST
    let params = {
      areaId: provinceId
    }
    return request({
      _this,
      errorMsg: '获取城市列表失败',
      body: { params },
      url,
      method: 'post'
    }).then(rsp => rsp.resData.areaList)
  },
  /**
   * 获取区域列表
   */
  getAreaList ({_this, cityId = 0}) {
    let url = API.COMMON.GET_AREA_LIST
    let params = {
      areaId: cityId
    }
    return request({
      _this,
      errorMsg: '获取区域列表',
      body: { params },
      url,
      method: 'post'
    }).then(rsp => rsp.resData.areaList)
  },

}
